package com.zj.fx.controller.info;

import com.zj.fx.common.base.BaseController;
import com.zj.fx.common.domain.AjaxResult;
import com.zj.fx.common.domain.ResultTable;
import com.zj.fx.model.custom.Tablepar;
import com.github.pagehelper.PageInfo;
import com.zj.fx.model.info.InfoSubcompany;
import com.zj.fx.model.info.InfoWeburl;
import com.zj.fx.service.info.InfoWeburlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * 填报说明文档相关网站地址Controller
 * @ClassName: InfoWeburlController
 * @author SQL
 * @date 2023-07-07 09:28:01
 */
@Api(value = "填报说明文档相关网站地址")
@Controller
@RequestMapping("/InfoWeburlController")
public class InfoWeburlController extends BaseController {

    private String prefix = "info/infoWeburl";

    @Autowired
    private InfoWeburlService infoWeburlService;


    /**
     * 填报说明文档相关网站地址页面展示
     * @param model
     * @return String
     * @author SQL
     */
    @ApiOperation(value = "分页跳转", notes = "分页跳转")
    @GetMapping("/view")
    @RequiresPermissions("gen:infoWeburl:view")
    public String view(ModelMap model) {
        return prefix + "/list";
    }

    /**
     * list集合
     * @param tablepar
     * @param
     * @return
     */
    //@Log(title = "填报说明文档相关网站地址", action = "111")
    @ApiOperation(value = "分页跳转", notes = "分页跳转")
    @GetMapping("/list")
    @RequiresPermissions("gen:infoWeburl:list")
    @ResponseBody
    public ResultTable list(Tablepar tablepar, InfoWeburl infoWeburl) {
        PageInfo<InfoWeburl> page = infoWeburlService.list(tablepar,infoWeburl);
        return pageTable(page.getList(), page.getTotal());
    }

    /**
     * 新增跳转
     */
    @ApiOperation(value = "新增跳转", notes = "新增跳转")
    @GetMapping("/add")
    public String add(ModelMap modelMap) {
        return prefix + "/add";
    }

    /**
     * 新增保存
     * @param 
     * @return
     */
    //@Log(title = "填报说明文档相关网站地址新增", action = "111")
    @ApiOperation(value = "新增", notes = "新增")
    @PostMapping("/add")
    @RequiresPermissions("gen:infoWeburl:add")
    @ResponseBody
    public AjaxResult add(@RequestBody InfoWeburl infoWeburl) {
        int b = infoWeburlService.insertSelective(infoWeburl);
        if (b > 0) {
            return success();
        } else {
            return error();
        }
    }

    /**
     * 填报说明文档相关网站地址删除
     * @param ids
     * @return
     */
    //@Log(title = "填报说明文档相关网站地址删除", action = "111")
    @ApiOperation(value = "删除", notes = "删除")
    @DeleteMapping("/remove")
    @RequiresPermissions("gen:infoWeburl:remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        int b = infoWeburlService.deleteByPrimaryKey(ids);
        if (b > 0) {
            return success();
        } else {
            return error();
        }
    }


    /**
     * 修改跳转
     * @param id
     * @param
     * @return
     */
    @ApiOperation(value = "修改跳转", notes = "修改跳转")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap map) {
        map.put("InfoWeburl", infoWeburlService.selectByPrimaryKey(id));

        return prefix + "/edit";
    }

    /**
     * 修改保存
     */
    //@Log(title = "填报说明文档相关网站地址修改", action = "111")
    @ApiOperation(value = "修改保存", notes = "修改保存")
    @RequiresPermissions("gen:infoWeburl:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody InfoWeburl infoWeburl) {
        return toAjax(infoWeburlService.updateByPrimaryKeySelective(infoWeburl));
    }

    /**
     * 检查编号是否唯一
     *
     * @return
     */
    @ApiOperation(value = "检查顺序号唯一", notes = "检查顺序号唯一")
    @PostMapping("/checkOrderUnique")
    @ResponseBody
    public int checkOrderUnique(InfoWeburl infoWeburl) {
        int b = infoWeburlService.checkOrderUnique(infoWeburl);
        if (b > 0) {
            return 1;
        } else {
            return 0;
        }
    }


}
